function palindromeLength(str) {
    let map = new Map();
    let count = 0;
    for (let index = 0; index < str.length; index++) {
        if (map.has(str[index])) {
            count += 2
            map.delete(str[index])
        } else {
            map.set(str[index], true)
        }
    }
    return count+(map.size > 1 ? 1: 0)
}


console.log(palindromeLength("acdf"))